﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

	<head>
		<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
		<title>ASP.NET MVC Controllers</title>
		<link type="text/css" rel="stylesheet" href="bootstrap.min.css" />
	</head>

	<body>

		<div class="document-contents">

			<h3>Introduction</h3>
			<p>ASP.NET Boilerplate is integrated to <strong>ASP.NET MVC Controllers</strong> via <strong>
Abp.Web.Mvc</strong> nuget package. You can create regular MVC Controllers as 
you always do. <a href="/Pages/Documents/Dependency-Injection">Dependency Injection</a> properly works for regular MVC Controllers. But you should derive your controllers from <strong>
	AbpController</strong>, which provides several benefits 
	and better integrates to ASP.NET Boilerplate.</p>
			<h3>AbpController Base Class</h3>
			<p>This is a simple controller derived from AbpController:</p>
			<pre lang="cs">public class HomeController : <strong>AbpController</strong>
{
    public ActionResult Index()
    {
        return View();
    }
}
			</pre>
			<h4>Localization</h4>
			<p>AbpController defines <strong>L</strong> method to make
				<a href="/Pages/Documents/Localization">localization</a> easier. Example:</p>
			<pre lang="cs">public class HomeController : AbpController
{
    public HomeController()
    {
        <strong>LocalizationSourceName = &quot;MySourceName&quot;;</strong>
    }

    public ActionResult Index()
    {
        var helloWorldText = <strong>L(&quot;HelloWorld&quot;)</strong>;

        return View();
    }
}</pre>
			<p>You should set <strong>LocalizationSourceName</strong> to make <strong>L</strong> method 
	working. You can set it in your own base controller class, to not repeat for 
	each controller.</p>

		<div class="document-contents">

			<h4>Others</h4>
			<p>You can also use pre-injected <a href="/Pages/Documents/Abp-Session">AbpSession</a>, 
				<a href="/Pages/Documents/EventBus-Domain-Events">EventBus</a>, 
				<a href="/Pages/Documents/Authorization">PermissionManager, PermissionChecker</a>, 
				<a href="/Pages/Documents/Setting-Management">SettingManager</a>, 
				<a href="/Pages/Documents/Feature-Management">FeatureManager, FeatureChecker</a>, 
				<a href="/Pages/Documents/Localization">LocalizationManager</a>, 
				<a href="/Pages/Documents/Logging">Logger</a>, 
				<a href="/Pages/Documents/Unit-Of-Work">CurrentUnitOfWork</a> base 
	properties and more.</p>

		</div>

			<h3>Filters</h3>
			<h4>Exception Handling &amp; Result Wrapping</h4>
			<p>All exceptions are automatically handled, logged and a proper response is 
	returned to the client. See <a href="/Pages/Documents/Handling-Exceptions">
	exception handling</a> documentation for more.</p>
			<p>ASP.NET Boilerplate also <strong>wraps</strong> action results by default if 
	return type is <strong>JsonResult</strong> (or Task&lt;JsonResult&gt; for async 
	actions).</p>
			<p>You can change exception handling and wrapping by using <strong>WrapResult</strong> and
				<strong>DontWrapResult</strong> 
	attributes for controllers or actions or from
			<a href="Startup-Configuration.html">startup configuration</a> 
			(using Configuration.Modules.AbpMvc()...) globally. See
				<a href="/Pages/Documents/Javascript-API/AJAX">ajax documentation</a> for more.</p>
			<h4>Audit Logging</h4>
			<strong>AbpMvcAuditFilter</strong> is used to integrate to
	<a href="Audit-Logging.html">audit logging system</a>. It logs all requests 
	to all actions by default (if auditing is not disabled). You can control audit logging using <strong>Audited</strong> and <strong>
	DisableAuditing</strong> attributes for actions and controllers.<h4>Validation</h4>
			<p><strong>AbpMvcValidationFilter</strong> automatically checks <strong>
			ModelState.IsValid</strong> and prevents execution of the action if 
			it's not valid. Also, implements input DTO validation described in 
			the <a href="Validating-Data-Transfer-Objects.html">validation 
			documentation</a>.</p>
			<h4>Authorization</h4>
			<p>You can use <strong>AbpMvcAuthorize</strong> attribute for your 
	controllers or actions to prevent unauthorized users to use your controllers 
	and actions. Example:</p>
			<pre lang="cs">public class HomeController : AbpController
{
    <strong>[AbpMvcAuthorize(&quot;MyPermissionName&quot;)]</strong>
    public ActionResult Index()
    {
        return View();
    }
}</pre>
			<p>You can define <strong>AllowAnonymous</strong> attribute for actions or controllers to suppress 
		authentication/authorization. AbpController also defines <strong>IsGranted</strong> method as a 
	shortcut to check permissions.</p>
			<p>See <a href="/Pages/Documents/Authorization">authorization</a> 
	documentation for more.</p>
			<h4>Unit Of Work</h4>

		</div>
	<p><strong>AbpMvcUowFilter</strong> is used to integrate to
	<a href="Unit-Of-Work.html">Unit of Work</a> system. It automatically begins 
	a new unit of work before an action execution and completes unit of work 
	after action exucition (if no exception is thrown).</p>
	<p>You can use <strong>UnitOfWork</strong> attribute to control behaviour of 
	UOW for an action. You can also use startup configuration to change default 
	unit of work attribute for all actions.</p>
		<h4>Anti Forgery</h4>
		<p><strong>AbpAntiForgeryMvcFilter</strong> is used to auto protect MVC 
		actions for POST, PUT and DELETE requests from CSRF/XSRF attacks. See
		<a href="XSRF-CSRF-Protection.html">CSRF documentation</a> for more.</p>
		<h3>Model Binders</h3>
		<p><strong>AbpMvcDateTimeBinder</strong> is used to normalize DateTime 
	(and Nullable&lt;DateTime&gt;) inputs using <strong>Clock.Normalize</strong> 
	method.</p>

	</body>

</html>
